home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual Foxpro 6.0 (Ent. Edition) / Vf6ent Extractor.EXE / TOOLS / XSOURCE / XSOURCE.ZIP / vfpsource / Coverage / COVERAGE.PRG < prev    next >
Encoding:
Text File  |  1998-05-01  |  3.8 KB  |  134 lines

  1. * COVERAGE WRAPPER PRG
  2.  
  3. #INCLUDE COVERAGE.H
  4.  
  5. LPARAMETERS tcFile, tlUnattended, tcAddIn
  6.  
  7. LOCAL oTemp, cAlias, lSuccess, lSetTalkBackOn, cAppFile ;
  8.       cLibs, cUnattendedMessage, cSavedTarget, cSavedSkippedFiles
  9.  
  10. IF (SET("TALK") = "ON")
  11.    SET TALK OFF
  12.    lSetTalkBackOn = .T.
  13. ENDIF
  14.  
  15. #IF COV_COMPILED_IN_VFP5
  16.    cLibs = SET("CLASSLIB")
  17.    cAlias = "C_"+SYS(2015)
  18. #ENDIF   
  19.  
  20. cAppFile = FindAppFile()
  21.  
  22. #IF COV_COMPILED_IN_VFP5
  23.    IF FILE(COV_CLASS_CLASSLIB) OR EMPTY(cAppFile)
  24.       SET CLASSLIB TO (COV_CLASS_CLASSLIB) ALIAS (cAlias) ADDITIVE
  25.    ELSE
  26.       SET CLASSLIB TO (COV_CLASS_CLASSLIB) IN (cAppFile) ALIAS (cAlias) ADDITIVE
  27.    ENDIF
  28.    oTemp = CREATEOBJECT(cAlias+"."+COV_CLASS_TO_INSTANCE, ;
  29.                         tcFile, tlUnattended, tcAddIn)
  30. #ELSE
  31.    oTemp = NEWOBJECT(COV_CLASS_TO_INSTANCE,COV_CLASS_CLASSLIB, cAppFile, ;
  32.                      tcFile, tlUnattended, tcAddIn)
  33. #ENDIF
  34.                                              
  35. * NB: the actual public reference variable
  36. * is not the responsibility of the wrapper program;
  37. * it's set up (and released when necessary)
  38. * by the object itself.
  39. * Absolutely nothing in this 
  40. * wrapper program is required.
  41. * An APP or EXE of some sort *is*
  42. * required, to make sure that the engine
  43. * can find its bits and pieces as necessary
  44. * when it's ready to instantiate them,
  45. * but it will take care of making sure
  46. * these bits and pieces are available itself.
  47.  
  48. lSuccess = (TYPE("oTemp.BaseClass") = "C")
  49.  
  50. IF lSuccess
  51.    IF tlUnattended
  52.       * oTemp.cSavedTargetDBF will have the
  53.       * marked code results file,
  54.       * and another table with the same
  55.       * name + numeric extension as your
  56.       * passed coverage log (in the same
  57.       * directory as the log)
  58.       * will show you what records were skipped
  59.       * if some source files were not found:
  60.       cSavedTarget = oTemp.cSavedTargetDBF
  61.       cSavedSkippedFiles = oTemp.cSavedSkipFiles
  62.       lSuccess = (NOT EMPTY(cSavedTarget))
  63.       IF lSuccess
  64.          cUnattendedMessage = COV_SAVEDTARGET_AS_LOC+C_CR+ ;
  65.             cSavedTarget+"." 
  66.          IF NOT EMPTY(cSavedSkippedFiles)
  67.             cUnattendedMessage = cUnattendedMessage + ;
  68.                                  C_DOUBLE_CR+;
  69.                                  COV_SAVEDSKIPFILES_AS_LOC+C_CR+;
  70.                                  "("+cSavedSkippedFiles+")."
  71.          ENDIF
  72.          MESSAGEBOX(cUnattendedMessage, COV_APPLICATION_NAME_LOC)
  73.       ENDIF
  74.       oTemp.Release()
  75.    ELSE
  76.       oTemp.Show()
  77.    ENDIF
  78. ELSE
  79.    CLEAR CLASS COV_CLASS_TO_INSTANCE
  80. ENDIF
  81.  
  82. #IF COV_COMPILED_IN_VFP5
  83.    SET CLASSLIB TO &cLibs
  84. #ENDIF   
  85.  
  86. IF lSetTalkBackOn
  87.    SET TALK ON
  88. ENDIF
  89.  
  90. IF NOT EMPTY(cSavedSkippedFiles)
  91.    SELECT 0
  92.    USE (cSavedSkippedFiles)
  93.    BROWSE NOWAIT WIDTH 30
  94.    MOVE WINDOW (WONTOP()) TO 0,0
  95. ENDIF
  96.  
  97. IF NOT EMPTY(cSavedTarget)
  98.    SELECT 0
  99.    USE (cSavedTarget)
  100.    BROWSE NOWAIT WIDTH 30
  101.    MOVE WINDOW (WONTOP()) TO 5,5   
  102. ENDIF
  103.  
  104. RETURN lSuccess
  105.  
  106.  
  107. PROCEDURE FindAppFile
  108. LOCAL cFileName, cSys16, iLevel
  109. * get the name of the module (app or exe) that
  110. * owns this particular object, for SET CLASSLIB ... IN...
  111. * or NEWOBJECT() filename parameter
  112.  
  113. * Finding this appfilename is most significant
  114. * in cases where this wrapper program
  115. * and its app get embedded in a temporary
  116. * program, such as when you highlight several
  117. * lines of code and interactively Execute them...
  118.  
  119. cFileName = ""
  120. FOR iLevel = 256 TO 1 STEP -1 && 256 = twice the nested programs currently allowed!
  121.   cSys16 = UPPER(SYS(16,iLevel))
  122.   IF INLIST(RIGHT(cSys16,3),"APP","EXE","VFD","DLL")
  123.      cFileName = cSys16
  124.      EXIT
  125.   ENDIF
  126. ENDFOR
  127.  
  128. IF "PROCEDURE" $ cFileName
  129.    cFileName = SUBSTR(cFileName,11)
  130.    cFileName = SUBSTR(cFileName,AT(" ",cFileName)+1)
  131. ENDIF
  132.  
  133. RETURN cFileName
  134.